package org.dyz.banana.platform.util.mappergen;


import org.dyz.banana.platform.util.config.CommonConfig;
import org.dyz.banana.platform.util.mappergen.constant.ValueConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.generator.config.rules.FileType;
@Component
public class MapperGeneratorForMybatis {
	
	@Autowired
	private CommonConfig commonConfig;
	
	public void generate() {
//		BananaMbgAutoGenerator systemMbgAutoGenerator = new BananaMbgAutoGenerator();
//		FileType[] businessFileTypes = new FileType[] {
//				FileType.CONTROLLER,
//				FileType.SERVICE,FileType.SERVICE_IMPL,FileType.MAPPER,FileType.XML
//		};
//		systemMbgAutoGenerator.setDefaultDataSourceConfig(commonConfig.url,
//				commonConfig.driver,commonConfig.username,commonConfig.password)
//		.setDefaultPackageConfig(PROJECT_PARENT_NAME, SYSTEM,businessFileTypes )
//		.setDefaultStrategyConfig(TableRegistry.SYSTEM_TABLE_LIST)
//		.setDefaultTemplateConfig(businessFileTypes)
//		.setDefaultGlobalConfig(WORKSPACE_DIR+SYSTEM);
//		systemMbgAutoGenerator.execute();
		
		
		BananaMbgAutoGenerator commonMbgAutoGenerator = new BananaMbgAutoGenerator();
		FileType[] entityFileTypes = new FileType[] {
				FileType.CONTROLLER,
				FileType.SERVICE,
				FileType.SERVICE_IMPL,
				FileType.MAPPER,
				FileType.XML,
				FileType.ENTITY
		};
		commonMbgAutoGenerator.setDefaultDataSourceConfig(commonConfig.url,
				commonConfig.driver,commonConfig.username,commonConfig.password)
		.setDefaultPackageConfig(ValueConstant.PROJECT_PARENT_NAME, ValueConstant.COMMON,entityFileTypes )
		.setDefaultStrategyConfig(TableRegistry.SYSTEM_TABLE_LIST)
		.setDefaultTemplateConfig(entityFileTypes)
		.setDefaultGlobalConfig(ValueConstant.WORKSPACE_DIR+ValueConstant.COMMON)
		.setInjectionConfig();
		commonMbgAutoGenerator.execute();
	}
	
	
	
}
